<template>
  <div class="menu-container">
    <nav>
      <RouterLink
        v-for="item in items"
        :key="item.name"
        :to="{ name: item.icon }"
        :exact="item.exact"
        active-class="selected"
        exact-active-class="selected"
      >
        <Icon :type="item.icon" :size="24" />
        <span>
          {{ item.title }}
        </span>
      </RouterLink>
    </nav>
  </div>
</template>

<script>
import Icon from "@/components/Icon/index.vue";
export default {
  name: "Menu",
  components: {
    Icon,
  },
  data() {
    return {
      items: [
        {
          title: "首页",
          icon: "home",
          exact: true, //是否精确匹配
        },
        {
          title: "文章",
          icon: "blog",
          exact: false,
        },
        {
          title: "关于我",
          icon: "about",
          exact: false,
        },
        {
          title: "项目&效果",
          icon: "project",
          exact: false,
        },
        {
          title: "留言板",
          icon: "message",
          exact: false,
        },
      ],
    };
  },
};
</script>

<style scoped lang="less">
@import "~@/styles/global.less";
.menu-container {
  width: 100%;
  color: @gray;
  a {
    display: block;
    display: flex;
    align-items: center;
    padding: 0 50px;
    height: 44px;
    i {
      margin-right: 10px;
    }
    &:hover {
      color: #fff;
    }
    &.selected {
      color: #fff;
      background-color: darken(@words, 5%);
    }
  }
}
</style>